import { DEFAULT_OPTS } from '@/settings'
import { defHttp } from '@/utils/http/axios'
import { IOrderedData, IOrderedDetailResp } from './model'

enum API {
  ORDER_LIST = '/orderManage/list',
  ORDERED = '/orderManage/',
  ORDERED_DETAIL = '/orderManage/detail'
}
export interface IOrderedRecord extends IOrderedData { key: string, order: string  }

/** 获取房间预约列表 */
export function getOrderedList() {
  return defHttp.get({
    url: API.ORDER_LIST
  }, DEFAULT_OPTS)
}

/** 新增预约 */
export function addOrdered(data: Omit<IOrderedData, 'id'>) {
  return defHttp.post({
    url: API.ORDERED,
    data
  }, DEFAULT_OPTS)
}

/** 编辑预约 */
export function editOrdered(data: IOrderedData) {
  return defHttp.put({
    url: API.ORDERED,
    data
  }, DEFAULT_OPTS)
}

/** 删除预约 */
export function deleteOrdered(id: string) {
  return defHttp.delete({
    url: API.ORDERED + id
  }, DEFAULT_OPTS)
}

/** 获取订单详情 */
export function getOrderedDetail(id: string) {
  return defHttp.get<IOrderedDetailResp>({
    url: API.ORDERED_DETAIL,
    params: {
      id
    }
  }, DEFAULT_OPTS)
}